import { Toast } from 'vant'
import { iswap } from '@ve/utils/pdaUtils'

// import isEmpty from 'lodash/isEmpty'
export default function openCapture({ vm, action, done }) {
  // let { getDataKey } = action.extension.requestConfig.value
  console.log('vm, action, done', vm, action, done)
  console.log('vm', action, window.$CIMC)
  if (iswap() == 'WEB') {
    window.$CIMC.playMusic('ERROR', '请在移动端设备上操作')
    return
  } else {
    window.$CIMC.openCapture((res) => {
      console.log('打开摄像头--', res)
      if (res.code == '200') {
        console.log('打开摄像头---22', res, JSON.stringify(res.data))
        done(null, { captureData: res.data })
      } else {
        Toast('打开摄像头失败')
        done(null, {})
      }
    })
  }
}
